// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_ok.java

package crm.sales_daily_work;

import include.nseer_cookie.NseerId;
import include.nseer_cookie.counter;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.net.URL;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;
	nseer_db_backup1 erp_db;

	public register_ok()
	{
		erp_db = null;
	}

	public synchronized void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		java.io.PrintWriter out = response.getWriter();
		nseer_db_backup1 crm_db = new nseer_db_backup1(dbApplication);
		nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
		try
		{
			String time = "";
			Date now = new Date();
			SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
			time = formatter.format(now);
			if (crm_db.conn((String)dbSession.getAttribute("unit_db_name")) && hr_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				counter count = new counter(dbApplication);
				String human_ID = request.getParameter("human_ID");
				String human_name = request.getParameter("human_name");
				String register_time = request.getParameter("register_time");
				String type = request.getParameter("type");
				String daily_work_ID = NseerId.getId(getClass().getResource("").toString(), (String)dbSession.getAttribute("unit_db_name"));
				String content = new String(request.getParameter("content").getBytes("UTF-8"), "UTF-8");
				String sql1 = (new StringBuilder("select * from hr_file where human_ID='")).append(human_ID).append("'").toString();
				ResultSet rs1 = hr_db.executeQuery(sql1);
				if (rs1.next())
				{
					String sql2 = (new StringBuilder("insert into crm_sales_daily_work(daily_work_ID,chain_ID,chain_name,human_ID,human_name,register,register_time,type,content,check_tag,excel_tag) values ('")).append(daily_work_ID).append("','").append(rs1.getString("chain_ID")).append("','").append(rs1.getString("chain_name")).append("','").append(human_ID).append("','").append(human_name).append("','").append(human_name).append("','").append(register_time).append("','").append(type).append("','").append(content).append("','0','2')").toString();
					crm_db.executeUpdate(sql2);
				}
				crm_db.commit();
				hr_db.commit();
				crm_db.close();
				hr_db.close();
				response.sendRedirect("crm/sales_daily_work/register_ok_a.jsp");
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
